package top.tomxwd.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import top.tomxwd.springcloud.pojo.Dept;
import top.tomxwd.springcloud.service.DeptClientService;

import java.util.List;

/**
 * RestFul风格
 *
 * @author xieweidu
 * @createDate 2020-06-05 22:08
 */
@RestController
public class DeptConsumerController {

    @Autowired
    private DeptClientService deptClientService;

    @GetMapping("/op/dept/get/{id}")
    public Dept getDeptById(@PathVariable("id") Long id) {
        return this.deptClientService.get(id);
    }

    @PostMapping("/op/dept/add")
    public boolean addDept(Dept dept) {
        return this.deptClientService.addDept(dept);
    }

    @GetMapping("/op/dept/list")
    public List<Dept> deptList() {
        return this.deptClientService.queryAll();
    }

}
